﻿//导入时间转换函数
document.write("<script language='javascript' src='/resources/js/views/enum.js'></script>");
document.write("<script language='javascript' src='/resources/js/date.js'></script>");
document.write("<script language='javascript' src='/resources/js/util.js'></script>");
document.write("<script language='javascript' src='/resources/js/views/commonFunction.js'></script>");

// 数据上报的类型_每年的目标值_数值_显示数据展示时效果的规则_每年的备注
// value="1_0.0_22.29_0_根据人口抽样数据推算",

// 颜色一致
// NO_DATA(3, "暂无数据"),
// NO_CITY(5, "市级免报"),
// NO_COUNTRY(6, "县级免报"),
var pipingLevel = [{"value":"1","text":"数值"},{"value":"2","text":"空格"},{"value":"3","text":"暂无数据"},
    {"value":"4","text":"时间"},{"value":"5","text":"市级免报"},{"value":"6","text":"县级免报"}];

function defineTableInitForm(w,h,t) {
    var height = window.screen.height;
    if (height > 500) {
        height = 400;
    }
    $('#dialogAdd').dialog({
        closed: true,
        title: t,
        width: w,
        height: height
    });
}

//配置report所有的列
var defineTableReportAllColumns = {
    "ck": {field:'ck', title:'',width:90, checkbox : true},
    "id": {field:'id',title:'ID',width:30, formatter: function (value, row, index) {
        return value;
    }},
    "dname": {field:'dname',title:'上报部门',width:100,formatter: function (value, row, index) {
        return value;
    }},
    "fname": {field:'fname',title:'报表名称',width:150, formatter: function (value, row, index) {
        return value;
    }},
    "indicator": {field:'indicator',title:'指标ID',width:220,align:'left',formatter: function (value, row, index) {
            return value;
        }},
    "iname": {field:'iname',title:'指标名称',width:220,align:'left',formatter: function (value, row, index) {
        return '<span title='+row.idesc+'>'+value+'</span>';
    }},
    "sname": {field:'sname',title:'资料来源',width:100,align:'center', formatter: function (value, row, index) {
        return value;
    }},
    "code": {field:'code',title:'汇总代码',width:80,align:'center',  sortable:'true',formatter: function (value, row, index) {
        return value;
    }},
    "memo": {field:'remark',title:'备注',width:150,align:'center',editor : 'text', formatter: function (value, row, index) {
        if(value!=null&&value!=undefined){
            return '<span title='+value+'>'+value+'</span>';
        }
        return '<span title=></span>'
    }},
    "description": {field:'description',title:'指标备注',width:150, formatter: function (value, row, index) {
        return '<span title='+value+'>'+value+'</span>'
    }},
    "value": {field:'value',title:'数值',width:100, formatter: function (value, row, index) {
        return getValueByVal(value);
    }},
    "unit": {field:'unit',title:'计量单位',width:80,align:'center', formatter: function (value, row, index) {
        return value;
    }},
    "places": {field:'places',title:'小数位',width:60,align:'center', formatter: function (value, row, index) {
        return value;
    }},
    "aim": {field:'aim',title:'终期目标值',width:70, formatter: function (value, row, index) {
        return value;
    }},
    "rule": {field:'rule',title:'规则类型',width:70, formatter: function (value, row, index) {
        return '<span title='+value+'>'+value+'</span>'
    }},
    "rname": {field:'rname',title:'规则类型',width:70, formatter: function (value, row, index) {
        return '<span title='+value+'>'+value+'</span>'
    }},

    //---------------------------------------------目标描述idesc(++)。目标规划值aim，规则类型。
    "idesc": {field:'idesc',title:'目标描述',width:150, formatter: function (value, row, index) {
        return '<span title='+value+'>'+value+'</span>'
    }},
    "cname": {field:'cname',title:'地市名称',width:60, formatter: function (value, row, index) {
        return value;
    }},
    "aname": {field:'aname',title:'地市名称',width:60, formatter: function (value, row, index) {
            return value;
     }},
    "year": {field:'year',title:'指标年份',width:60, align: 'right', formatter: function (value, row, index) {
        switch(value) {
            case 0 : return '不限年限';
        }
        return value;
    }},
    "rtype": {field:'rtype',title:'数据类型',width:40,
        formatter: function (value, row, index) {
            if(value==null||value==0){
                return pipingLevel[0].text;
            }
            for(var i =0;i<pipingLevel.length;i++){
                if(pipingLevel[i].value==value){
                    return pipingLevel[i].text;
                }
            }
        },
        editor:{
            type:"combobox",
            options: {
                data:pipingLevel,
                valueField: "value",
                textField: "text",
                editable: true
            }
        }
    },
    "country": {field:'country',title:'国家指标',width:80,formatter: function (value, row, index) {
        switch(value) {
            case 0 : return '非国家指标';
            case 1 : return '国家指标';
        }
        return '未知';
    }},
    "need": {field:'need',title:'是否上报',width:80,formatter: function (value, row, index) {
        switch(value) {
            case 1 : return '必须上报';
            case 2 : return '可免报';
        }
        return '未知';
    }},
    "mtime": {field:'mtime',title:'上报时间',width:110,formatter: function (value, row, index) {
        return (formatDate(new Date(parseInt(value)), "yyyy-MM-dd hh:mm:ss"));
    }},
    // "base": {field:'remark',title:'备注',width:250,align:'center',editor : 'text', formatter: function (value, row, index) {
    //     if(value!=null&&value!=undefined){
    //         return '<span title='+value+'>'+value+'</span>';
    //     }
    //     return '<span title=></span>'
    // }},
    "hide": {field:'hide',title:'数据是否公开',width:80,formatter: function (value, row, index) {
        switch(value) {
            case 1 : return '可公开数据';
            case 2 : return '仅内部可看';
        }
        return '未知';
    }},
    "status": {field:'status',title:'状态',width:30,formatter: function (value, row, index) {
        switch(value) {
            case 0 : return '删除';
            case 1 : return '正常';
        }
        return '未知';
    }},
    "auditFormulas": {field:'auditFormulas',title:'审核关系公式',width:80,align:'center', formatter: function (value, row, index) {//----新增点
        return value;
    }},
    "goalDescrip": {field:'goalDescrip',title:'目标描述',width:150, formatter: function (value, row, index) {//-------------------------新增点
        return '<span title='+value+'>'+value+'</span>'
    }},
    "opration": {field:' ', title:'操作',width:60,align:'center',formatter: function(value,row,index){
        var up = "<a style='color:blue' onclick='up("+row["id"]+")'>上移</a>";
        var down = "<a style='color:blue' href='#' title=\"下移\" href='#' onclick='down("+row["id"]+")'>下移</a>";

        var modify = "<a style='color:blue' href='#' onclick='modify("
            +row["id"]+","
            +"\""+row["name"]+"\""+","
            +"\""+row["code"]+"\""+","
            +row["type"]+","
            +row["pid"]+","
            +"\""+row["unit"]+"\""+","
            +row["places"]+","
            +"\""+row["aim"]+"\""+","
            +row["year"]+","
            +row["country"]+","
            +row["need"]+","
            +row["hide"]+","
            +"\""+row["description"]+"\""
            +")'>修改</a>";
        var del = "<a style='color:blue' href='#' onclick='del("+row["id"]+")'>删除</a>";

        if(row["status"]==0){
            //return up + "&nbsp;" + down + "&nbsp;" + modify;
            return modify;
        }
//                            	                    return up + "&nbsp;"+ down + "&nbsp;"+ modify + "&nbsp;" + del;
        return modify + "&nbsp;" + del;
    }}
};

function getDefineTableReportColumnsDepartFormsValue(year) {
    var remark = {field:year, title:'当年备注', width:90, align:"center",
        formatter : function(value, row, index) {
            var tempValue;
            if(value.indexOf('_')!=-1){
                tempValue = value.split('_')[4];
            }
            return tempValue;
        }
    };
    var result=defineTableReportColumnsDepartFormsValue;
    result.push(remark);
    return [result];
}

var defineTableReportColumnsDepartFormsValue = [
    defineTableReportAllColumns["ck"],
    defineTableReportAllColumns["iname"],
    defineTableReportAllColumns["code"],
    defineTableReportAllColumns["unit"],
    defineTableReportAllColumns["places"],
    defineTableReportAllColumns["sname"]
];

var defineTableIndicatorType = {
    "ck": {field:'ck', title:'',width:90, checkbox : true},
    "id": {field:'id',title:'指标类型ID',width:60, formatter: function (value, row, index) {
        return value;
    }},
    "formsid": {field:'formsid',title:'指标',width:100,formatter: function (value, row, index) {
        return value;
    }},
    "code": {field:'code',title:'编码',width:150, formatter: function (value, row, index) {
        return value;
    }},
    "name": {field:'name',title:'指标类型',width:200,align:'left',formatter: function (value, row, index) {
        return value;
    }},
    "sort": {field:'sort',title:'排序',width:100,align:'center', sortable:'true', formatter: function (value, row, index) {
        return value;
    }},
    "status": {field:'status',title:'状态',width:100,align:'center',  formatter: function (value, row, index) {
        return value;
    }}
};

var defineTableIndicatorTypeColumnsName = [
    defineTableIndicatorType["ck"],
    defineTableIndicatorType["id"],
    defineTableIndicatorType["name"]
];

var defineTableIndicatorTypeColumns = [[
    {field:'id',title:'ID',width:50},
    {field:'name',title:'表名',width:130},
    {field:'code',title:'表号',width:70},
    {field:'making',title:'制定机关',width:150},
    {field:'number',title:'批准文号',width:80},
    {field:'rate',title:'期别',width:50},
    {field:'expire',title:'有效期至',width:80},
    {field:'remark',title:'说明',width:300}
    // ,
    // {field:'status',title:'状态',width:100,formatter: function (value, row, index) {
    //     switch(value) {
    //         case 0 : return '删除';
    //         case 1 : return '正常';
    //     }
    //     return '未知';
    // }}
    // ,
    // {field:' ', title:'操作',width:200,align:'center',formatter: function(value,row,index){
    //     var up = "<a style='color:blue' onclick='up("+row["id"]+")'>上移</a>";
    //     var down = "<a style='color:blue' href='#' title=\"下移\" href='#' onclick='down("+row["id"]+")'>下移</a>";
    //     var modify = "<a style='color:blue' href='#' onclick='modify("+row["id"]+",\""+row["name"]+"\""+",\""+row["code"]+"\")'>修改</a>";
    //     var del = "<a style='color:blue' href='#' onclick='del("+row["id"]+")'>删除</a>";
    //
    //     if(row["status"]==0){
    //         //return up + "&nbsp;" + down + "&nbsp;" + modify;
    //         return modify;
    //     }
    //     //return up + "&nbsp;"+ down + "&nbsp;"+ modify + "&nbsp;" + del;
    //     return modify + "&nbsp;" + del;
    // }}
]];


//指标管理
var defineTableIndicatorColumns = {
    "ck": {field:'ck', title:'',width:90, checkbox : true},
    "id": {field:'id',title:'指标ID',width:60, formatter: function (value, row, index) {
        return value;
    }},
    /*  "tname": {field:'tname',title:'领域',width:80, formatter: function (value, row, index) {
          return value;
      }},*/
    "name500": {field:'name',title:'指标名称',width:500, formatter: function (value, row, index) {
        return value;
    }},
    "iname": {field:'iname',title:'指标名称',width:180, formatter: function (value, row, index) {
            return value;
        }},
    "name": {field:'name',title:'指标名称',width:180, formatter: function (value, row, index) {
            return value;
        }},
    "namewith": {field:'name',title:'指标名称', formatter: function (value, row, index) {
            return value;
        }},
    "tyname": {field:'name',title:'指标领域名称', formatter: function (value, row, index) {
            return value;
        }},
    "code": {field:'code',title:'汇总代码',width:80, sortable:'true', formatter: function (value, row, index) {
        return value;
    }},
    "unit": {field:'unit',title:'计量单位',width:50, formatter: function (value, row, index) {
        return value;
    }},
    "places": {field:'places',title:'小数位',width:50, formatter: function (value, row, index) {
        return value;
    }},
    // "base": {field:'base',title:'当年目标值',width:80, formatter: function (value, row, index) {
    //     return value;
    // }},
    "aim": {field:'aim',title:'终期目标值',width:80, formatter: function (value, row, index) {
        return value;
    }},
    "rule": {field:'rule',title:'规则类型',width:100, formatter: function (value, row, index) {
        switch(value) {
            case 1 : return '逐年上升';
            case 2 : return '逐年下降';
            case 3 : return '存在一定比例';
            case 4 : return '大于目标值';
            case 5 : return '等于目标值';
            case 6 : return '小于目标值';
            case 7 : return '大于等于目标值';
            case 8 : return '小于等于目标值';
        }
        return '';
    }},
    /* "year": {field:'year',title:'指标年份',width:60, align: 'right', formatter: function (value, row, index) {
         switch(value) {
             case 0 : return '不限年限';
         }
         return value;
     }},
     "country": {field:'country',title:'国家指标',width:80,formatter: function (value, row, index) {
         switch(value) {
             case 0 : return '非国家指标';
             case 1 : return '国家指标';
         }
         return '未知';
     }},
     "need": {field:'need',title:'是否上报',width:80,formatter: function (value, row, index) {
         switch(value) {
         case 1 : return '必须上报';
         case 2 : return '可免报';
         }
         return '未知';
     }},
     "hide": {field:'hide',title:'数据是否公开',width:80,formatter: function (value, row, index) {
         switch(value) {
         case 1 : return '可公开数据';
         case 2 : return '仅内部可看';
         }
         return '未知';
     }},*/
    /*  "mtime": {field:'mtime',title:'最后修改时间',width:120,formatter: function (value, row, index) {
          return (formatDate(new Date(parseInt(value)), "yyyy-MM-dd hh:mm:ss"));
      }},*/
    /* "status": {field:'status',title:'状态',width:30,formatter: function (value, row, index) {
         switch(value) {
         case 0 : return '删除';
         case 1 : return '正常';
         }
         return '未知';
     }},
     "opration": {field:' ', title:'操作',width:100,align:'center',formatter: function(value,row,index){
         var up = "<a style='color:blue' onclick='up("+row["id"]+")'>上移</a>";
         var down = "<a style='color:blue' href='#' title=\"下移\" href='#' onclick='down("+row["id"]+")'>下移</a>";

         var modify = "<a style='color:blue' href='#' onclick='modify("
             +row["id"]+","
             +"\""+row["name"]+"\""+","
             +"\""+row["code"]+"\""+","
             +row["type"]+","
             +row["pid"]+","
             +"\""+row["unit"]+"\""+","
             +row["places"]+","
             +"\""+row["aim"]+"\""+","
             +row["rule"]+","
             +row["country"]+","
             +row["need"]+","
             +row["hide"]+","
             +"\""+row["idesc"]+"\""
             +"\""+row["description"]+"\""+","
             +")'>修改</a>";

         if(row["status"]==0){
             return up + "&nbsp;" + down
//		    	+ "&nbsp;" + modify
             ;
         }
         return up + "&nbsp;"+ down
//	        + "&nbsp;"+ modify
         ;
     }}*/
}

var defineTableIndicatorOnlyNames = [
    defineTableIndicatorColumns["namewith"],
    defineTableIndicatorColumns["code"],
    defineTableIndicatorColumns["unit"],
    defineTableIndicatorColumns["places"]
];
var defineTableIndicatorOnlyNamesModel = [
    // defineTableReportAllColumns["indicator"],
    defineTableReportAllColumns["iname"],
    defineTableIndicatorColumns["code"],
    defineTableIndicatorColumns["unit"],
    defineTableIndicatorColumns["places"]
];

var defineTableIndicatorNamesModel = [
    defineTableIndicatorColumns["ck"],
    defineTableReportAllColumns["iname"],
    defineTableIndicatorColumns["code"],
    defineTableIndicatorColumns["unit"],
    defineTableIndicatorColumns["places"]
];
var defineTableIndicatorNames = [
    defineTableIndicatorColumns["ck"],
    defineTableIndicatorColumns["namewith"],
    defineTableIndicatorColumns["code"],
    defineTableIndicatorColumns["unit"],
    defineTableIndicatorColumns["places"]
];
var defineTableIndicatorTypeNames = [
    defineTableIndicatorColumns["ck"],
    defineTableIndicatorColumns["tyname"]
];

var defineTableIndicatorColumnsNames = [
    defineTableIndicatorColumns["ck"],
    defineTableIndicatorColumns["id"],
    defineTableIndicatorColumns["code"],
    defineTableIndicatorColumns["name500"]
];

var defineTableIndicatorShowColumns = [
    defineTableIndicatorColumns["id"],
    /*defineTableIndicatorColumns["tname"],*/
    defineTableIndicatorColumns["name"],
    defineTableIndicatorColumns["code"],
    defineTableIndicatorColumns["unit"],
    defineTableIndicatorColumns["places"],
    // defineTableIndicatorColumns["base"],
    defineTableIndicatorColumns["aim"],
    defineTableIndicatorColumns["rule"]
//       defineTableIndicatorColumns["year"],
    /*defineTableIndicatorColumns["country"],
    defineTableIndicatorColumns["need"],
    defineTableIndicatorColumns["hide"]*/
    /* defineTableIndicatorColumns["mtime"],*/
//       defineTableIndicatorColumns["status"],
    /* defineTableIndicatorColumns["opration"]*/
];

//部门所有的列
var defineTableDepartColumns = {
    "id": {field:'id',title:'ID',width:30, formatter: function (value, row, index) {
        return value;
    }},
    "name": {field:'name',title:'部门名称',width:150, formatter: function (value, row, index) {
        return value;
    }},
    "sname": {field:'sname',title:'部门简称',width:100, formatter: function (value, row, index) {
        return value;
    }},
    "pname": {field:'pname',title:'上级部门',width:150, formatter: function (value, row, index) {
        return value;
    }},
    "area": {field:'area',title:'所属地域ID',width:150, formatter: function (value, row, index) {
        return value;
    }},
    "aname": {field:'aname',title:'所属地域',width:100, formatter: function (value, row, index) {
        return value;
    }},
    "code": {field:'code',title:'部门编号',width:80, formatter: function (value, row, index) {
        return value;
    }},
    "typename": {field:'typename',title:'部门类别',width:80, formatter: function (value, row, index) {
        return value;
    }},
    "level": {field:'level',title:'部门级别',width:80, formatter: function (value, row, index) {
        switch(value) {
            case 1 : return '国家级';
            case 2 : return '省/部级';
            case 3 : return '地/市级';
            case 4 : return '区/县级';
            case 5 : return '乡/镇级';
            case 0 : return '其他';
        }
        return '';
    }},
    "pid": {field:'pid',title:'上级部门',width:100, formatter: function (value, row, index) {
        return value;
    }},
    "charge": {field:'charge',title:'部门负责人',width:60, align: 'right', formatter: function (value, row, index) {
        return value;
    }},
    "phone": {field:'phone',title:'联系电话',width:80,formatter: function (value, row, index) {
        return value;
    }},
    "author": {field:'author',title:'统计负责人',width:80,formatter: function (value, row, index) {
            return value;
        }},
    "contact": {field:'contact',title:'联系人',width:80,formatter: function (value, row, index) {
        return value;
    }},
    "email": {field:'email',title:'联系邮箱',width:120,formatter: function (value, row, index) {
        return value;
    }},
    "address": {field:'address',title:'联系地址',width:120,formatter: function (value, row, index) {
        return value;
    }},
    "editor": {field:'editor',title:'编辑人',width:50,formatter: function (value, row, index) {
        return value;
    }},
    "mtime": {field:'mtime',title:'最后修改时间',width:120,formatter: function (value, row, index) {
        return (formatDate(new Date(parseInt(value)), "yyyy-MM-dd hh:mm:ss"));
    }},
    "status": {field:'status',title:'状态',width:30,formatter: function (value, row, index) {
        switch(value) {
            case 0 : return '删除';
            case 1 : return '正常';
        }
        return '未知';
    }},
    "opration": {field:' ', title:'操作',width:100,align:'center',formatter: function(value,row,index){
        var modify = "<a style='color:blue' href='#' onclick='modify("
            +row["id"]+","
            +"\""+row["code"]+"\""+","
            +"\""+row["name"]+"\""+","
            +"\""+row["sname"]+"\""+","
            +row["type"]+","
            +row["level"]+","
            +row["pid"]+","
            +row["area"]+","
            +"\""+row["charge"]+"\""+","
            +"\""+row["phone"]+"\""+","
            +"\""+row["author"]+"\""+","
            +"\""+row["email"]+"\""+","
            +"\""+row["address"]+"\""
            +")'>修改</a>";

        var del = "<a style='color:blue' href='#' onclick='del("+row["id"]+")'>删除</a>";

        if(row["status"]==0){
            return modify;
        }
        return modify + "&nbsp;" + del;
    }},
}

var defineTableDepartShowColumns = [
    defineTableDepartColumns["id"],
    defineTableDepartColumns["name"],
    defineTableDepartColumns["sname"],
    defineTableDepartColumns["code"],
    defineTableDepartColumns["typename"],
    defineTableDepartColumns["level"],
    defineTableDepartColumns["pname"],
    defineTableDepartColumns["aname"],
    defineTableDepartColumns["charge"],
    defineTableDepartColumns["phone"],
    defineTableDepartColumns["contact"],
    defineTableDepartColumns["author"],
    defineTableDepartColumns["email"],
    defineTableDepartColumns["address"],
    defineTableDepartColumns["editor"],
    defineTableDepartColumns["mtime"],
    defineTableDepartColumns["status"],
    defineTableDepartColumns["opration"]
];

//地域所有的列
var defineTableAreaColumns = {
    "id": {field:'id',title:'ID',width:30, formatter: function (value, row, index) {
        return value;
    }},
    "name": {field:'name',title:'地域名称',width:150, formatter: function (value, row, index) {
        return value;
    }},
    "pid": {field:'pid',title:'父级地域ID',width:100, formatter: function (value, row, index) {
        return value;
    }},
    "pname": {field:'pname',title:'父级地域名称',width:150, formatter: function (value, row, index) {
        return value;
    }},
    "code": {field:'code',title:'地域编号',width:80, formatter: function (value, row, index) {
        return value;
    }},
    "level": {field:'level',title:'部门级别',width:80, formatter: function (value, row, index) {
        switch(value) {
            case 1 : return '国家';
            case 2 : return '省/直辖市';
            case 3 : return '地/市';
            case 4 : return '区/县';
            case 5 : return '乡/镇';
            case 6 : return '其他';
        }
        return '未知';
    }},
    "ctime": {field:'ctime',title:'创建时间',width:120,formatter: function (value, row, index) {
        return (formatDate(new Date(parseInt(value)), "yyyy-MM-dd hh:mm:ss"));
    }},
    "mtime": {field:'mtime',title:'最后修改时间',width:120,formatter: function (value, row, index) {
        return (formatDate(new Date(parseInt(value)), "yyyy-MM-dd hh:mm:ss"));
    }},
    "status": {field:'status',title:'状态',width:30,formatter: function (value, row, index) {
        switch(value) {
            case 0 : return '删除';
            case 1 : return '正常';
        }
        return '未知';
    }},
    "opration": {field:' ', title:'操作',width:100,align:'center',formatter: function(value,row,index){

        var up = "<a style='color:blue' onclick='up("+row["id"]+")'>上移</a>";
        var down = "<a style='color:blue' href='#' title=\"下移\" href='#' onclick='down("+row["id"]+")'>下移</a>";

        var modify = "<a style='color:blue' href='#' onclick='modify("
            +row["id"]+","
            +"\""+row["code"]+"\""+","
            +"\""+row["name"]+"\""+","
            +"\""+row["pname"]+"\""+","
            +row["level"]+","
            +row["pid"]
            +")'>修改</a>";

        var del = "<a style='color:blue' href='#' onclick='del("+row["id"]+")'>删除</a>";

        //如果是山东省,则不能编辑啊
        if(row["code"]=="SHANDONG"){
            return up + "&nbsp;" + down;
        }
        if(row["status"]==0){
            return up + "&nbsp;" + down + "&nbsp;" + modify;
        }
        return up + "&nbsp;"+ down + "&nbsp;"+ modify + "&nbsp;" + del;
    }},
}

var defineTableAreaShowColumns = [
    defineTableAreaColumns["id"],
    defineTableAreaColumns["name"],
    defineTableAreaColumns["pname"],
    defineTableAreaColumns["level"],/*
    defineTableAreaColumns["ctime"],
    defineTableAreaColumns["mtime"],*/
    defineTableAreaColumns["status"],
    defineTableAreaColumns["opration"]
];


var defineTableDepartColumns = [[
    {field:'id',title:'ID',width:30},
    {field:'name',title:'部门名称',width:100},
    {field:'sname',title:'部门简称',width:50},
    {field:'code',title:'部门编号',width:50},
//    {field:'type',title:'类别ID',width:50},
    {field:'typename',title:'部门类别',width:50},
    {field:'level',title:'部门级别',width:50,formatter: function (value, row, index) {
        switch(value) {
            case 1 : return '国家级';
            case 2 : return '省/部级';
            case 3 : return '地/市级';
            case 4 : return '区/县级';
            case 5 : return '乡/镇级';
            case 0 : return '其他';
        }
        return '';
    }},
    {field:'pid',title:'上级部门',width:50},
    {field:'charge',title:'部门负责人',width:50},
    {field:'author',title:'统计负责人',width:50},
    {field:'phone',title:'联系电话',width:60},
    {field:'contact',title:'联系人',width:50},
    {field:'email',title:'联系邮箱',width:80},
    {field:'address',title:'联系地址',width:80},
    {field:'editor',title:'编辑人',width:60},
    {field:'mtime',title:'最后修改时间',width:80,formatter: function (value, row, index) {
        return (formatDate(new Date(parseInt(value)), "yyyy-MM-dd hh:mm:ss"));
    }},
    {field:'status',title:'状态',width:30,formatter: function (value, row, index) {
        switch(value) {
            case 0 : return '删除';
            case 1 : return '正常';
        }
        return '未知';
    }},
    {field:' ', title:'操作',width:60,align:'center',formatter: function(value,row,index){
        var modify = "<a style='color:blue' href='#' onclick='modify("
            +row["id"]+","
            +"\""+row["code"]+"\""+","
            +"\""+row["name"]+"\""+","
            +"\""+row["sname"]+"\""+","
            +row["type"]+","
            +row["level"]+","
            +row["pid"]+","
            +"\""+row["charge"]+"\""+","
            +"\""+row["phone"]+"\""+","
            +"\""+row["author"]+"\""+","
            +"\""+row["email"]+"\""+","
            +"\""+row["address"]+"\""
            +")'>修改</a>";

        var del = "<a style='color:blue' href='#' onclick='del("+row["id"]+")'>删除</a>";

        if(row["status"]==0){
            return modify;
        }
        return modify + "&nbsp;" + del;
    }}
]];

